package base.study.chapter9;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * List
 */
public class List2Array {

    class Employee {
        private String name;

        public Employee(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Employee{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }

    @Test
    public void list2Array() {
        ArrayList<Employee> list = new ArrayList<>();
        list.add(new Employee("a"));
        list.add(new Employee("d"));
        list.add(new Employee("c"));
        list.add(new Employee("d"));
        Employee[] employees = list.toArray(new Employee[list.size()]);

        System.out.println(employees.length);

        System.out.println(Arrays.toString(employees));
    }
}
